package com.haoyu.microservicecloudconsumercategory80.controller;

import com.haoyu.microservicecloudapi.entity.Category;
import com.haoyu.microservicecloudconsumercategory80.service.CategoryService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: 蒿雨
 * @create: 2022-04-14 10:17
 * @description:
 */
@Controller
public class CategoryController {

    @Resource
    private CategoryService categoryService;


    @RequestMapping("/list")
    @ResponseBody
    public List<Category> list() {
        return categoryService.list();
    }

    @RequestMapping("/get/{id}")
    @ResponseBody
    public Category get(@PathVariable Integer id) {
        return categoryService.get(id);
    }

    @RequestMapping("/update")
    @ResponseBody
    public boolean update(@RequestBody Category category) {
        return categoryService.update(category);
    }

    @RequestMapping("/insert")
    @ResponseBody
    public boolean insert(@RequestBody Category category) {
        return categoryService.insert(category);
    }

    @RequestMapping("/delete/{id}")
    public boolean delete(@PathVariable Integer id) {
        return categoryService.delete(id);
    }

}
